import { priceFormat, renderTableText, tableSorter } from '@/utils';

// Table表格的配置
const getTableColumns = () => {
  return [
    {
      title: '材料名称',
      dataIndex: 'assetName',
      key: 'assetName',
      width: 60,
      fixed: 'left',
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '材料品牌',
      dataIndex: 'brandTypeName',
      key: 'brandTypeName',
      width: 60,
      sorter: (a: any, b: any) => tableSorter(a, b, 'brandTypeName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '材料来源',
      dataIndex: 'sourceTypeName',
      key: 'sourceTypeName',
      width: 60,
      sorter: (a: any, b: any) => tableSorter(a, b, 'sourceTypeName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '仓库',
      dataIndex: 'assetStoreName',
      key: 'assetStoreName',
      width: 60,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetStoreName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '参考单价（元）',
      dataIndex: 'assetValue',
      key: 'assetValue',
      visible: true,
      width: 80,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetValue'),
      render: (text: number | any) => {
        return <span>{text ? priceFormat(text) : `0.00`}</span>;
      },
    },
    {
      title: '数量',
      dataIndex: 'quantityOrArea',
      key: 'quantityOrArea',
      visible: true,
      width: 60,
      sorter: (a: any, b: any) => tableSorter(a, b, 'quantityOrArea'),
      render: (text: number) => {
        return <span>{text ? text : `0`}</span>;
      },
    },
    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 60,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
  ];
};

export { getTableColumns };
